home *** CD-ROM | disk | FTP | other *** search
Oberon Text | 1996-01-09 | 19.4 KB | 461 lines |
- Syntax10.Scn.Fnt
- Syntax10i.Scn.Fnt
- Syntax10b.Scn.Fnt
- FoldElems
- MODULE PopupElems; (** Original by Michael Franz, 27.1.92, SHML, MH, CM 5 Sep 94 **)
- (* new file format, added Version tag and options, drop down menu by CM, Uni Linz *)
- (* change ErrorMsg, Save, Restore if necessary! *)
- IMPORT
- Amiga, Pictures, Oberon, Input, Display, Viewers, Files, Fonts, Printer,
- Texts, TextFrames, MenuViewers, TextPrinter, Modules;
- CONST
- VersionTag = 01X; CR = 0DX;
- menuElem = 0; underlined = 1; (* elem is a MenuElem, MenuElem is underlined *)
- ElemDW = 4; ElemDH = 2; MenuDW = 3; MenuDH = 1; (* margins of element box and menu box *)
- DUnit = TextFrames.Unit; PUnit = TextPrinter.Unit;
- MR = 0; MM = 1; ML = 2; cancel = {ML, MM, MR};
- white = Display.white; black = Display.black;
- paint = Display.paint; replace = Display.replace; invert = Display.invert;
- TYPE
- Elem = POINTER TO ElemDesc;
- ElemDesc = RECORD (Texts.ElemDesc)
- name: ARRAY 32 OF CHAR;
- menu: Texts.Text;
- n, default, width, lsp, dsc: INTEGER; (* number of items, default item, width, line space, descender *)
- options: SET (* menuElem, underlined *)
- END;
- EditFrame = POINTER TO EditFrameDesc;
- EditFrameDesc = RECORD (TextFrames.FrameDesc)
- elem: Elem
- END;
- VAR wr: Texts.Writer; buf: Texts.Buffer; saveArea:Pictures.Picture; xeHandle: Display.Handler;
- PROCEDURE Str(s: ARRAY OF CHAR); BEGIN Texts.WriteString(wr, s) END Str;
- PROCEDURE Ln; BEGIN Texts.WriteLn(wr) END Ln;
- (* non_portable stuff *)
- PROCEDURE ErrorMsg(name: ARRAY OF CHAR; res: INTEGER); (* not portable!!! *)
- BEGIN
- IF res > 0 THEN
- Str("Call error: "); Str(Modules.importing);
- IF res = 1 THEN Str(" not found")
- ELSIF res = 2 THEN Str(" not an obj-file")
- ELSIF res = 3 THEN
- Str(" imports ");
- Str(Modules.imported); Str(" with bad key")
- ELSIF res = 4 THEN Str(" corrupted obj file")
- ELSIF res = 6 THEN Str(" has too many imports")
- ELSIF res = 7 THEN Str(" not enough space")
- END
- ELSIF res < 0 THEN Str(name); Str(" not found")
- END;
- IF res # 0 THEN Ln; Texts.Append(Oberon.Log, wr.buf) END
- END ErrorMsg;
- PROCEDURE GetXEHandler;
- VAR save, par: Oberon.ParList; res: INTEGER;
- BEGIN
- save := Oberon.Par;
- NEW(par); NEW(par.frame); par.frame.X := 0; par.frame.Y := 0; par.pos := -210566; (* magic *)
- Oberon.Call("XE.GetHandler", par, FALSE, res);
- IF res = 0 THEN xeHandle := Oberon.Par.frame.handle
- ELSE xeHandle := TextFrames.Handle
- END;
- Oberon.Par := save
- END GetXEHandler;
- PROCEDURE Save(X, Y, W, H: INTEGER); (* copy from screen X, Y, W, H into save area *)
- BEGIN
- Pictures.Create(saveArea,W,H,Amiga.Depth);
- Pictures.CopyBlock(Display.screen,saveArea,X,Y,W,H,0,0,replace)
- END Save;
- PROCEDURE Restore(X, Y, W, H: INTEGER); (* restore from save area to screen X, Y, W, H *)
- BEGIN
- Pictures.CopyBlock(saveArea,Display.screen,0,0,W,H,X,Y,replace)
- END Restore;
- (* auxiliary *)
- PROCEDURE Min(x, y: INTEGER): INTEGER; BEGIN IF x < y THEN RETURN x ELSE RETURN y END END Min;
- PROCEDURE Max(x, y: INTEGER): INTEGER; BEGIN IF x > y THEN RETURN x ELSE RETURN y END END Max;
- PROCEDURE CopyText(from: Texts.Text): Texts.Text;
- VAR to: Texts.Text;
- BEGIN Texts.Save(from, 0, from.len, buf); to := TextFrames.Text(""); Texts.Append(to, buf); RETURN to
- END CopyText;
- PROCEDURE DefaultMenu(e: Elem);
- BEGIN
- IF e.menu.len > 0 THEN Texts.Delete(e.menu, 0, e.menu.len) END;
- Str("right interclick to edit menu"); Ln; Texts.Append(e.menu, wr.buf)
- END DefaultMenu;
- PROCEDURE GetName(e: Elem; t: Texts.Text; pos: LONGINT);
- VAR s: Texts.Scanner;
- BEGIN
- Texts.OpenScanner(s, t, pos); Texts.Scan(s);
- IF ~(s.class IN {Texts.Name, Texts.String}) OR (s.s[0] = 0X) THEN e.name := "Popup" ELSE COPY(s.s, e.name) END
- END GetName;
- PROCEDURE StrDispWidth(fnt: Fonts.Font; s: ARRAY OF CHAR): LONGINT;
- VAR pat: Display.Pattern; width, i, dx, x, y, w, h: INTEGER;
- BEGIN
- width := 0; i := 0;
- WHILE s[i] # 0X DO Display.GetChar(fnt.raster, s[i], dx, x, y, w, h, pat); INC(width, dx); INC(i) END;
- RETURN LONG(width)*DUnit
- END StrDispWidth;
- PROCEDURE DispStr(fnt: Fonts.Font; s: ARRAY OF CHAR; col, x0, y0: INTEGER);
- VAR pat: Display.Pattern; i, dx, x, y, w, h: INTEGER;
- BEGIN
- i := 0;
- WHILE s[i] # 0X DO
- Display.GetChar(fnt.raster, s[i], dx, x, y, w, h, pat);
- Display.CopyPattern(col, pat, x0+x, y0+y, paint);
- INC(i); INC(x0, dx)
- END
- END DispStr;
- (* change propagation *)
- PROCEDURE PrepareDraw(e: Elem; fnt: Fonts.Font; VAR dy: INTEGER);
- VAR width, dh: INTEGER;
- BEGIN
- IF menuElem IN e.options THEN width := 0; dh := 0; dy := fnt.minY; IF dy > -2 THEN dy := -2 END
- ELSE width := 2*ElemDW+4; dh := -fnt.minY+2*ElemDH+2 END;
- e.W := LONG(width)*DUnit+StrDispWidth(fnt, e.name)+DUnit; e.H := LONG(fnt.maxY-fnt.minY+dh)*DUnit
- END PrepareDraw;
- PROCEDURE PrepareMenu(e: Elem);
- VAR r: Texts.Reader; ch, oldCh: CHAR; width, dx, x, y, w, h: INTEGER; p: LONGINT;
- BEGIN
- e.width := 0; e.n := 1; e.lsp := 0; width := 0; oldCh := 0X;
- Texts.OpenReader(r, e.menu, 0); Texts.Read(r, ch);
- WHILE ~r.eot DO
- IF ch = CR THEN e.width := Max(e.width, width); width := 0; INC(e.n)
- ELSE
- e.lsp := Max(e.lsp, r.fnt.height); e.dsc := Min(e.dsc, r.fnt.minY);
- Display.GetChar(r.fnt.raster, ch, dx, x, y, w, h, p); INC(width, dx)
- END;
- oldCh := ch; Texts.Read(r, ch)
- END;
- IF oldCh = CR THEN DEC(e.n) END;
- IF (oldCh = 0X) OR (e.n = 0) OR (e.width+width = 0) THEN (* ensure non_empty text *)
- DefaultMenu(e); PrepareMenu(e)
- ELSE e.width := Max(e.width, width); e.default := Min(e.default, e.n-1)
- END
- END PrepareMenu;
- (* interactive editing of popup menus *)
- PROCEDURE HandleEdit(f: Display.Frame; VAR msg: Display.FrameMsg);
- VAR f1: EditFrame;
- BEGIN
- xeHandle(f, msg);(*TextFrames.Handle(f, msg)*)
- WITH f: EditFrame DO
- IF msg IS Oberon.CopyMsg THEN
- NEW(f1);
- TextFrames.Open(f1, f.text, f.org);
- f1.handle := f.handle; f1.elem := f.elem; msg(Oberon.CopyMsg).F := f1
- END
- END
- END HandleEdit;
- PROCEDURE OpenEditor(e: Elem);
- CONST menu = "System.Close Edit.Search Edit.Replace PopupElems.Toggle Menu Line PopupElems.Update ";
- VAR v: MenuViewers.Viewer; f: EditFrame; x, y, i: INTEGER; name: ARRAY 34 OF CHAR;
- BEGIN
- name[0] := 22X; i := 0; (* 22X = " *)
- WHILE e.name[i] # 0X DO name[i+1] := e.name[i]; INC(i) END;
- name[i+1] := 22X; name[i+2] := 0X;
- Oberon.AllocateUserViewer(Oberon.Mouse.X, x, y);
- NEW(f); f.elem := e; TextFrames.Open(f, CopyText(e.menu), 0); f.handle := HandleEdit;
- v := MenuViewers.New(TextFrames.NewMenu(name, menu), f, TextFrames.menuH, x, y)
- END OpenEditor;
- (* file input/output *)
- PROCEDURE Load(VAR r: Files.Rider; e: Elem);
- VAR ch: CHAR; val: LONGINT;
- BEGIN
- Files.Read(r, ch);
- IF ch = VersionTag THEN
- Files.ReadString(r, e.name);
- Files.ReadNum(r, val); e.default := SHORT(val);
- Files.ReadSet(r, e.options); e.options := e.options*{menuElem, underlined};
- e.menu := TextFrames.Text(""); Texts.Load(r, e.menu)
- ELSE
- Files.Set(r, Files.Base(r), Files.Pos(r)-1);
- Files.ReadString(r, e.name);
- Files.Read(r, ch);
- IF ch >= 80X THEN e.options := {menuElem, underlined} ELSE e.options := {} END;
- e.default := ORD(ch) MOD 128;
- e.menu := TextFrames.Text(""); Texts.Load(r, e.menu)
- END
- END Load;
- PROCEDURE Store(VAR r: Files.Rider; e: Elem);
- BEGIN
- Files.Write(r, VersionTag);
- Files.WriteString(r, e.name); Files.WriteNum(r, e.default); Files.WriteSet(r, e.options);
- Texts.Store(r, e.menu)
- END Store;
- (* graphics *)
- PROCEDURE Box(col, bkgnd, X, Y, W, H: INTEGER);
- BEGIN
- Display.ReplConst(col, X+1, Y+1, W-2, 1, replace);
- Display.ReplConst(col, X+1, Y+H-2, W-2, 1, replace);
- Display.ReplConst(col, X+1, Y+2, 1, H-4, replace);
- Display.ReplConst(col, X+W-2, Y+2, 1, H-4, replace);
- Display.ReplConst(col, X+4, Y, W-4, 1, replace);
- Display.ReplConst(col, X+W-1, Y+1, 1, H-4, replace);
- Display.ReplConst(bkgnd, X+2, Y+2, W-4, H-4, replace)
- END Box;
- PROCEDURE Underline(f: Display.Frame; col, X, Y, W: INTEGER);
- BEGIN Display.ReplPatternC(f, white, Display.grey1, X, Y, W, 1, X, Y, invert)
- END Underline;
- PROCEDURE DrawElem(e: Elem; f: Display.Frame; pos: LONGINT; fnt: Fonts.Font; col, X, Y: INTEGER);
- VAR beg: LONGINT; parc: TextFrames.Parc; bkgndCol: INTEGER;
- BEGIN
- IF f IS TextFrames.Frame THEN bkgndCol := f(TextFrames.Frame).col ELSE bkgndCol := black END;
- IF menuElem IN e.options THEN
- TextFrames.ParcBefore(Texts.ElemBase(e), pos, parc, beg);
- INC(Y, SHORT(parc.dsr DIV DUnit));
- IF bkgndCol = col THEN col := ABS(white-col) END
- ELSE
- Box(col, bkgndCol, X, Y, SHORT((e.W-1) DIV DUnit), SHORT(e.H DIV DUnit));
- INC(X, ElemDW+2); INC(Y, ElemDH+2-fnt.minY)
- END;
- DispStr(fnt, e.name, col, X, Y);
- IF e.options*{menuElem, underlined} = {menuElem, underlined} THEN
- Underline(f, col, X, Y-2, SHORT(e.W DIV DUnit))
- END
- END DrawElem;
- PROCEDURE PrintElem(e: Elem; fnt: Fonts.Font; X, Y: INTEGER);
- VAR W, H: INTEGER;
- BEGIN
- W := SHORT((e.W-1) DIV PUnit); H := SHORT(e.H DIV PUnit);
- IF menuElem IN e.options THEN
- Printer.String(X, Y, e.name, fnt.name);
- IF underlined IN e.options THEN Printer.ReplConst(X, Y-2, W, 1) END
- ELSE
- Printer.ReplConst(X+1, Y+1, W-2, 1);
- Printer.ReplConst(X+1, Y+H-2, W-2, 1);
- Printer.ReplConst(X+1, Y+2, 1, H-4);
- Printer.ReplConst(X+W-2, Y+2, 1, H-4);
- Printer.ReplConst(X+4, Y, W-4, 1);
- Printer.ReplConst(X+W-1, Y+1, 1, H-4);
- Printer.String(X + (ElemDW+2) * DUnit DIV PUnit,
- Y + SHORT(LONG(ElemDH+2-fnt.minY)*DUnit DIV PUnit), e.name, fnt.name
- END
- END PrintElem;
- PROCEDURE DrawMenu(e: Elem; X, Y, W, H: INTEGER);
- VAR r: Texts.Reader; ch: CHAR; X0, dx, x, y, w, h: INTEGER; p: LONGINT;
- BEGIN
- Box(white, black, X, Y, W, H);
- X0 := X+MenuDW+2; X := X0; Y := Y+H-e.lsp-e.dsc-MenuDH-2;
- Texts.OpenReader(r, e.menu, 0); Texts.Read(r, ch);
- WHILE ~r.eot DO
- IF ch = CR THEN Y := Y-e.lsp; X := X0
- ELSE
- Display.GetChar(r.fnt.raster, ch, dx, x, y, w, h, p);
- Display.CopyPattern(r.col, p, X+x, Y+y, paint); INC(X, dx)
- END;
- Texts.Read(r, ch)
- END
- END DrawMenu;
- (* actions *)
- PROCEDURE Show(f: Display.Frame; e: Elem; pos: LONGINT; X, Y: INTEGER; VAR cmd: INTEGER; VAR keySum: SET);
- VAR
- eX, eY, eW, eH, W, H, w, newY, mx, my, top, bot, left, right, newCmd: INTEGER;
- keys: SET;
- parc: TextFrames.Parc; beg: LONGINT;
- default: BOOLEAN;
- PROCEDURE FlipLine;
- BEGIN Display.ReplConst(white, eX, eY, eW, 2, invert)
- END FlipLine;
- PROCEDURE Flip(cmd: INTEGER);
- BEGIN IF cmd >= 0 THEN Display.ReplConst(white, left, top-(cmd+1)*e.lsp, right-left, e.lsp, invert) END
- END Flip;
- BEGIN
- eX := X; eY := Y; eW := SHORT(e.W DIV DUnit); eH := SHORT(e.H DIV DUnit);
- IF (menuElem IN e.options) & (e.n = 1) THEN (* one_liner MenuElem *)
- TextFrames.ParcBefore(Texts.ElemBase(e), pos, parc, beg);
- newY := eY+SHORT(parc.dsr DIV DUnit);
- IF underlined IN e.options THEN Underline(f, white, eX, newY-2, eW) END;
- FlipLine; newCmd := cmd;
- REPEAT
- Input.Mouse(keys, mx, my); keySum := keySum+keys;
- Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, mx, my);
- IF (keySum = cancel) OR (mx < eX) OR (mx >= eX+eW) OR (my < eY) OR (my >= eY+eH) THEN newCmd := -1
- ELSIF (cmd = -1) & (eX <= mx) & (mx < eX+eW) & (eY <= my) & (my < eY+eH) THEN newCmd := e.default
- END;
- IF newCmd # cmd THEN FlipLine; cmd := newCmd END
- UNTIL keys = {};
- IF cmd # -1 THEN FlipLine END;
- IF underlined IN e.options THEN Underline(f, white, eX, newY-2, eW) END
- ELSE
- Input.Mouse(keys, mx, my);
- W := e.width + 2*MenuDW + 4; H := e.n*e.lsp + 2*MenuDH + 4;
- IF (W > Oberon.DisplayWidth(X)) OR (H > Oberon.DisplayHeight(X)) THEN
- Str("PopupElem too big!"); Ln; Texts.Append(Oberon.Log, wr.buf);
- REPEAT Input.Mouse(keys, mx, my); Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, mx, my)
- UNTIL keys = {};
- keySum := cancel; cmd := -1
- ELSE
- w := Oberon.DisplayWidth(X); left := Display.Left;
- X := Min(w-W, Max(mx-W DIV 2, left)); (* X >= left & X+W <= w *)
- newY := my-((e.n-cmd)*e.lsp-e.lsp DIV 2);
- IF (newY >= Display.Bottom) & (newY+H <= Oberon.DisplayHeight(X)) THEN (* popup at mouse pos *)
- Y := newY; default := FALSE
- ELSE (* drop down *)
- IF Y-H > Display.Bottom THEN Y := Y-H ELSE Y := Y+eH END;
- IF Y+H > Oberon.DisplayHeight(X) THEN Y := Display.Bottom END;
- default := TRUE
- END;
- left := X+3; right := X+W-3; bot := Y+MenuDH+3; top := Y+H-MenuDH-2;
- Oberon.RemoveMarks(X, Y, W, H); Oberon.FadeCursor(Oberon.Mouse);
- Save(X, Y, W, H); (* save background *)
- DrawMenu(e, X, Y, W, H);
- Flip(cmd); keySum := {};
- REPEAT
- Input.Mouse(keys, mx, my); keySum := keySum+keys;
- Oberon.DrawCursor(Oberon.Mouse, Oberon.Arrow, mx, my);
- IF keySum = cancel THEN cmd := -1
- ELSIF (mx >= left) & (mx <= right) & (my >= bot) & (my <= top) THEN
- newCmd := (top-my) DIV e.lsp;
- IF newCmd # cmd THEN default := FALSE; Flip(cmd); Flip(newCmd); cmd := newCmd END
- ELSIF default THEN
- IF (eX <= mx) & (mx < eX+eW) & (eY <= my) & (my < eY+eH) THEN
- IF cmd # e.default THEN cmd := e.default; Flip(cmd) END
- ELSE Flip(cmd); cmd := -1
- END
- ELSIF ~default THEN Flip(cmd); cmd := -1
- END
- UNTIL keys = {};
- Oberon.FadeCursor(Oberon.Mouse);
- Restore(X, Y, W, H) (* restore background *)
- END
- END
- END Show;
- PROCEDURE Popup(e: Elem; msg: TextFrames.TrackMsg);
- VAR
- cmd, res: INTEGER; s: Texts.Scanner; r: Texts.Reader; ch: CHAR; keys: SET;
- par: Oberon.ParList;
- BEGIN
- keys := msg.keys; cmd := e.default;
- Show(msg.frame, e, msg.pos, msg.X0, msg.Y0, cmd, keys);
- IF keys = {MM, MR} THEN OpenEditor(e)
- ELSIF (keys # cancel) & (cmd > -1) THEN
- e.default := cmd;
- Texts.OpenReader(r, e.menu, 0); Texts.Read(r, ch);
- WHILE cmd > 0 DO IF ch = CR THEN DEC(cmd) END; Texts.Read(r, ch) END;
- Texts.OpenScanner(s, e.menu, Texts.Pos(r)-1); Texts.Scan(s);
- IF (s.class = Texts.Name) & (s.line = 0) THEN
- NEW(par); par.frame := msg.frame;
- IF (menuElem IN e.options) & (e.n = 1) & s.eot THEN (* setup text following MenuElem as parameter *)
- par.text := Texts.ElemBase(e); par.pos := msg.pos+1
- ELSE par.text := e.menu; par.pos := Texts.Pos(s)-1
- END;
- Oberon.Call(s.s, par, ML IN keys, res); (* left interclick -> unload module *)
- IF res # 0 THEN ErrorMsg(s.s, res) END
- END
- END
- END Popup;
- (* element *)
- PROCEDURE Handle(e: Texts.Elem; VAR msg: Texts.ElemMsg);
- VAR copy: Elem;
- BEGIN
- WITH e: Elem DO
- IF msg IS TextFrames.DisplayMsg THEN
- WITH msg: TextFrames.DisplayMsg DO
- IF msg.prepare THEN PrepareDraw(e, msg.fnt, msg.Y0)
- ELSE DrawElem(e, msg.frame, msg.pos, msg.fnt, msg.col, msg.X0, msg.Y0)
- END
- END
- ELSIF msg IS TextPrinter.PrintMsg THEN
- WITH msg: TextPrinter.PrintMsg DO
- IF ~msg.prepare THEN PrintElem(e, msg.fnt, msg.X0, msg.Y0) END
- END
- ELSIF msg IS Texts.CopyMsg THEN
- WITH msg: Texts.CopyMsg DO
- NEW(copy); Texts.CopyElem(e, copy);
- copy.name := e.name; copy.menu := CopyText(e.menu);
- copy.n := e.n; copy.default := e.default; copy.width := e.width; copy.lsp := e.lsp; copy.dsc := e.dsc;
- copy.options := e.options;
- msg.e := copy
- END
- ELSIF msg IS Texts.IdentifyMsg THEN
- WITH msg: Texts.IdentifyMsg DO
- msg.mod := "PopupElems"; msg.proc := "Alloc"
- END
- ELSIF msg IS Texts.FileMsg THEN
- WITH msg: Texts.FileMsg DO
- IF msg.id = Texts.load THEN Load(msg.r, e); PrepareMenu(e)
- ELSIF msg.id = Texts.store THEN Store(msg.r, e)
- END
- END
- ELSIF msg IS TextFrames.TrackMsg THEN
- WITH msg: TextFrames.TrackMsg DO Popup(e, msg) END
- END
- END
- END Handle;
- PROCEDURE Alloc*;
- VAR e: Elem;
- BEGIN NEW(e); e.handle := Handle; Texts.new := e
- END Alloc;
- (** commands **)
- PROCEDURE insert(options: SET);
- VAR e: Elem; ins: TextFrames.InsertElemMsg;
- BEGIN
- NEW(e); GetName(e, Oberon.Par.text, Oberon.Par.pos); e.options := options;
- e.menu := TextFrames.Text(""); DefaultMenu(e); PrepareMenu(e);
- e.handle := Handle; ins.e := e; Viewers.Broadcast(ins)
- END insert;
- PROCEDURE Insert*; BEGIN insert({underlined}) END Insert;
- PROCEDURE InsertMenu*; BEGIN insert({menuElem, underlined}) END InsertMenu;
- PROCEDURE Toggle*; (** "Menu" | "Line" Change option of element(s) in frame below or in selected text **)
- VAR f: TextFrames.Frame; s: Texts.Scanner; r: Texts.Reader; t: Texts.Text; flag: INTEGER; beg, end, time: LONGINT;
- PROCEDURE Translate(str: ARRAY OF CHAR; VAR val: INTEGER);
- BEGIN
- IF str = "Menu" THEN val := menuElem
- ELSIF str = "Line" THEN val := underlined
- ELSE val := -1
- END
- END Translate;
- PROCEDURE Change(e: Elem; opt: INTEGER);
- VAR text: Texts.Text;
- BEGIN
- e.options := e.options / {opt};
- text := Texts.ElemBase(e);
- IF text # NIL THEN text.notify(text, Texts.replace, Texts.ElemPos(e), Texts.ElemPos(e)+1) END
- END Change;
- BEGIN
- IF Oberon.Par.frame = Oberon.Par.vwr.dsc THEN
- f := Oberon.Par.frame(TextFrames.Frame);
- IF f.hasSel THEN Texts.OpenScanner(s, f.text, f.selbeg.pos)
- ELSE Texts.OpenScanner(s, f.text, Oberon.Par.pos)
- END;
- Texts.Scan(s);
- IF s.class = Texts.Name THEN
- Translate(s.s, flag);
- IF flag # -1 THEN Change(f.next(EditFrame).elem, flag) END
- END
- ELSE
- Texts.OpenScanner(s, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(s);
- IF s.class = Texts.Name THEN
- Oberon.GetSelection(t, beg, end, time);
- IF time >= 0 THEN
- Translate(s.s, flag);
- IF flag # -1 THEN
- Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
- WHILE (Texts.Pos(r) <= end) & (r.elem # NIL) DO
- IF r.elem IS Elem THEN Change(r.elem(Elem), flag) END;
- Texts.ReadElem(r)
- END
- END
- END
- END
- END
- END Toggle;
- PROCEDURE Update*;
- VAR f: EditFrame; e: Elem; s: Texts.Scanner; menuText, text: Texts.Text; pos: LONGINT;
- BEGIN
- IF Oberon.Par.frame = Oberon.Par.vwr.dsc THEN
- f := Oberon.Par.frame.next(EditFrame); e := f.elem; menuText := Oberon.Par.frame(TextFrames.Frame).text;
- GetName(e, menuText, 0);
- Texts.OpenScanner(s, menuText, 0); Texts.Scan(s);
- IF ~(s.class IN {Texts.Name, Texts.String}) OR (s.s[0] = 0X) THEN s.s := "Popup" END;
- COPY(s.s, e.name); e.menu := CopyText(f.text);
- PrepareMenu(e);
- text := Texts.ElemBase(e);
- IF text # NIL THEN
- pos := Texts.ElemPos(e); text.notify(text, Texts.replace, pos, pos+1);
- Texts.OpenReader(s, menuText, menuText.len-1); Texts.Read(s, s.c);
- IF s.c = "!" THEN Texts.Delete(menuText, menuText.len-1, menuText.len) END
- END
- END
- END Update;
- BEGIN NEW(buf); Texts.OpenBuf(buf); Texts.OpenWriter(wr); GetXEHandler; NEW(saveArea)
- END PopupElems.
-